package com.neuedu.autosale.cli.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.neuedu.autosale.cli.entity.Client;
import com.neuedu.autosale.cli.service.ClientService;
import com.neuedu.autosale.entity.Pager;
import com.neuedu.autosale.entity.Result;
import com.neuedu.autosale.mapper.ClientMapper;


@Service
@Transactional
public class ClientServiceImpl implements ClientService {
	@Autowired
	private ClientMapper clientMapper;
	
	@Override
	public List<Client> findListByPager(Pager<Client> pager){
		return clientMapper.findListBypager(pager);
	}
	
	@Override
	public Integer findTotalByPager(Pager<Client> pager) {
		return clientMapper.findTotalByPager(pager);
	}
	
	@Override
	public Result add(Client object) {
		Result result =new Result(false,"新增失败！");
		boolean ret=clientMapper.add(object);
		if(ret) {
			result=new Result(true,"新增成功！");
		}
		return result;
	}
	
	@Override
	public Result edit(Client object) {
		Result result =new Result(false,"修改失败！");
		boolean ret=clientMapper.edit(object);
		if(ret) {
			result= new Result(true,"修改成功!");
		}
		return result;
	}
	
	@Override
	public Result deleteByIds(List<Client> ids) {
		Result result = new Result(false, "删除失败！");
		boolean ret = clientMapper.deleteByIds(ids);
		if (ret) {
			result = new Result(true, "删除成功！");
		}
		return result;
	}
	
	@Override
	public List<Client> findAll(){
		return clientMapper.findAll();
	}
	
	@Override
	public Client login(Client client) {
		return clientMapper.login(client);
	}
}
